import sys
from PyQt5.QtWidgets import QWidget, QApplication, QPushButton, QDesktopWidget

app = QApplication(sys.argv)
w = QWidget()  # 创建一个窗口
w.resize(400, 400)  # 设置窗口大小
w.move(300, 300)  # 设置窗口位置
w.setWindowTitle("屏幕坐标系")  # 设置窗口标题

# 获取窗口在屏幕上的位置
x = w.x()
y = w.y()
print("窗口在屏幕上的位置：x = %d, y = %d" % (x, y))
# 获取窗口在屏幕上的大小
width = w.width()
height = w.height()
print("窗口在屏幕上的大小：width = %d, height = %d" % (width, height))

# 获取屏幕尺寸大小
screen = app.primaryScreen()
screen_size = screen.size()
print("屏幕尺寸大小：width = %d, height = %d" % (screen_size.width(), screen_size.height()))

screen_rect = QDesktopWidget().screenGeometry()  # 获取屏幕分辨率
print("屏幕分辨率：width = %d, height = %d" % (screen_rect.width(), screen_rect.height()))
# 获取屏幕可用大小
available_size = QDesktopWidget().availableGeometry()
print("屏幕可用大小：width = %d, height = %d" % (available_size.width(), available_size.height()))



button1 = QPushButton("关闭窗口", w)
button1.move(0, 0)  # 设置按钮位置

w.show()  # 显示窗口

sys.exit(app.exec_())
